﻿using System.Drawing;
using System.Data;

using OpenChart.Entities;
using OpenChart.PublicUnits;

namespace OpenChart.DrawChart
{
    class DrawingLogarithmDotChart:DrawingLogarithmLineChart
    {
        /// <summary>
        /// 绘制数据
        /// </summary>
        protected override void DrawData()
        {
            base.DrawData();
        }

        /// <summary>
        /// 绘制Series
        /// </summary>
        /// <param name="item">Series</param>
        protected override void DrawOneSeries(Series item)
        {
            PointF tempPoint;
            double tempXValue, tempYValue;
            foreach (DataRow row in this.ChartArea.Data.Rows)
            {
                tempXValue = ChartHelper.GetDoubleValue(row[this.ChartArea.XValueMember], this.ChartArea.AxisX.IntervalType);
                tempYValue = ChartHelper.GetDoubleValue(row[item.YValueMember], this.ChartArea.AxisY1.IntervalType);
                tempPoint = this.GetPoint(tempXValue, tempYValue);
                this.DrawPoint(tempPoint,item.Color,item.Width);
            }
        }

        //绘制一个点
        private void DrawPoint(PointF point, Color color, int width)
        {
            Brush brush = new SolidBrush(color);
            Pen pen = new Pen(brush, width);
            this.Graphics.DrawEllipse(pen, point.X - (float)width / 2, point.Y - (float)width / 2, width, width);
        }
    }
}
